package com.shiguiwu.springmybatis.spring.lifecycle.init;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

/**
 * @description: 9.4初始化后阶段
 * @author: stone
 * @date: Created by 2021/3/28 13:07
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.lifecycle.init
 */
public class AfterInitializeTests {
    public static void main(String[] args) {
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        //叫一个初始化后处理器
        factory.addBeanPostProcessor(new MyBeanPostProcessor());

        AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(String.class)
                .addConstructorArgValue( "shiguiwu")
                .getBeanDefinition();

        AbstractBeanDefinition beanDefinition1 = BeanDefinitionBuilder.genericBeanDefinition(Integer.class)
                .addConstructorArgValue(15)
                .getBeanDefinition();

        factory.registerBeanDefinition("shiguiwuabc", beanDefinition);
        factory.registerBeanDefinition("shiguiwuA", beanDefinition1);

        System.out.println(factory.getBean(String.class));
        System.out.println(factory.getBean(Integer.class));
    }
}
